
	function createSetupPanel(){

			var storeField=['index','data'];
			var setupStore=CRM.commons.createStore('setupStore',storeField,'setup/listsetups');
		    var modulesGrid=CRM.commons.createGrid('modulesGridid',setupStore,new Ext.grid.ColumnModel([
		    	{
			    	header:'Modules',
			    	dataIndex:'data',
				    width:230,
				    align:'center',
				    menuDisabled:true
		    	},
		    	{
					header:'id',
					dataIndex:'index',
					hidden:true
		    	}
		    ]));
		    
			modulesGrid.setSize(250,400);
			modulesGrid.getSelectionModel().on('rowselect',function(sm, rowIndex, r){
			   	attributeGrid.store.reload({
						params:{
			   					 moduleid:rowIndex
								}
				});
			   	attrValuesGrid.store.removeAll();
				attrValuesGrid.store.reload({
						params:{
	    						 setupModuleid:rowIndex,
	    						 setupAttributeid:0
								}
		    	});
			});
				    
			var attArray=['index','data'];
			var atrrStore=CRM.commons.createStore('atrrStore',attArray,'setup/listAttributes');
		    var attributeGrid=CRM.commons.createGrid('attributeGrid',atrrStore,new Ext.grid.ColumnModel([
		    	{
		    		header:'Attributes',
					dataIndex:'data',
					width:230,
					align:'center',
				    menuDisabled:true
		    	},
	    		{
					header:'id',
					dataIndex:'index',
					hidden:true
		    	}
		    ]));
				    
		    attributeGrid.setSize(250,400);
		    attributeGrid.getSelectionModel().on('rowselect',function(sm, rowIndex, r){
				    				var modGrid=Ext.getCmp('modulesGridid');
				    				attrValuesGrid.store.reload({
										params:{
				    					setupModuleid:modGrid.getSelectionModel().getSelected().get('index'),
				    					setupAttributeid:attributeGrid.getSelectionModel().getSelected().get('index')
										}
					    	});
					    });

		    var attValueArray=['id','fieldValue'];
			var atrrValueStore=CRM.commons.createStore('atrrStore',attValueArray,'setup/listAttributeValues');
					
		    var attrValuesGrid=CRM.commons.createGrid('attrValuesGrid',atrrValueStore,new Ext.grid.ColumnModel([
				{
					header:'Attribute Values',
				    dataIndex:'fieldValue',
				    width:230,
				    align:'center',
				    menuDisabled:true
				},
				{
					header:'id',
					dataIndex:'id',
					hidden:true
		    	},
		    	{
					xtype:'actioncolumn',
					header:'Action',
					align:'center',
					menuDisabled:true,
					items:[
					       {
							icon:'../images/cross.gif',
							tooltip:'Delete',
							handler:function(sm,rowIndex,colIndex){
								var row=attrValuesGrid.store.getAt(rowIndex);
								saveAction('setup/saveAttrvalue?setupValueid='+row.get('id'),'remove');
								}
					        }
					      ]
				}
		    ]));
		    
		    attrValuesGrid.setSize(350,400);

		    var gridspan=new Ext.Panel({
		    	xtype:'panel',
				id:'setupsid',
				layout:'column',
				width:1000,
				items:[
						{
							xtype:'fieldset',
							items:[modulesGrid]
						},
						{
							xtype:'fieldset',
							items:[attributeGrid]
						},
						{
							xtype:'fieldset',
							items:[attrValuesGrid,
									{
										xtype:'compositefield',
										id:'attrvalueid',
										items:[
												{
													xtype:'textfield',
													id:'setupAttrValue',
													fieldLabel:'Attribute Value'
												},
												{
													xtype:'button',
													text:'Add',
													handler:function(){saveAction('setup/saveAttrvalue','save');}
												 }
												]
									}
						]
					}
				]
		    });
		    var setupPanel = new Ext.FormPanel({
		    	id          : 'setupPanel',
		    	//renderTo    : Ext.getBody(),
		    	height      : 670,
		    	width       : 1340,
		    	frame       : false,
		    	layout      : 'vbox',
		    	items       : [ 
		    	               {
		    	            	   xtype:'panel',
		    	            	   title:'Setups',
		    	            	   id:'setupid',
		    	            	   items:[gridspan]
		    	               }
		    	               ],
		    	 listners	:{
		                   		afterrender:function(){alert();
				    				modulesGrid.getSelectionModel().selectRow(0);	
		                   		}
                        	 }      
	          });
		return setupPanel;	    
	}

		function saveAction(path,methodtype)
		{
			var formPanel = Ext.getCmp('setupPanel');
			var modGrid=Ext.getCmp('modulesGridid');
			var attribGrid=Ext.getCmp('attributeGrid');
			var valueGrid=Ext.getCmp('attrValuesGrid');
			var attribValue=Ext.getCmp('setupAttrValue');
			
			
			Ext.Ajax.request({
				url: path,
				method: 'POST',
				params:{
					setupAttrValue:attribValue.getValue(),
					operation:methodtype,
					setupModuleid:modGrid.getSelectionModel().getSelected().get('index'),
					setupAttributeid:attribGrid.getSelectionModel().getSelected().get('index')
				},
				
				success: function() 
				{ 
					valueGrid.store.reload({
						params:{
							setupModuleid:modGrid.getSelectionModel().getSelected().get('index'),
							setupAttributeid:attribGrid.getSelectionModel().getSelected().get('index')
						}
					   								
					});
					attribValue.setValue(null);
				},
				failure: function() { alert ("Failure");}
			});
		}
